<%@page import="Entities.*"%>
<%@page import="Helpers.*"%>
<%@page import="Hibernate.*"%>
<%@page import="java.util.*"%>

<%@include file="../../views/header.jsp" %>
<%@include file="../../views/mainMenu.jsp" %>
<%@include file="../../views/userMenu.jsp" %>
<%@include file="../../views/cntColumnOpen.jsp" %>


     <%
        String enquetenaam = (String) request.getParameter("enquetenaam");
        //show form
        if (enquetenaam == null) {
     %>


<h2>Aanmaken enquete</h2>


<form id="form6" name="form6" class="wufoo leftLabel" method="post" action="webpages/Enquete/voegEnqueteToe.jsp">

    <ul>
        <li id="1" class="section">
            <h3 id="title8">Enquete behorende bij een cursus</h3>
        </li>
        <br />
        <li id="fo6li115" class="complex">
            <label class="desc" id="title115" for="curus">
                Cursus
                <span id="req_115" class="req">*</span>
            </label>
            <div>
                <select id="cursusid" name="cursusid" class="field select addr" tabindex="14" >
                    <%
                        List<Cursussen> cursussen = chelper.getcursussen();
                        for (Cursussen cursus : cursussen) {
                    %>
                        <option value="<%=cursus.getId()%>"><%=cursus.getNaam()%></option>
                    <% }%>
                </select>
            </div>
        </li>

        <li id="2" class="complex">
           <label class="desc" id="title117" for="toets">
             Enquete <span id="req_117" class="req">*</span>
           </label>
           <span>
              <input id="enquetenaam" name="enquetenaam" type="text" class="field text" size="30"  />
           </span>
        </li>

        <li id="3" class="complex">
           <label class="desc" id="title118" for="toets">
             Aantal vragen <span id="req_118" class="req">*</span>
           </label>
           <span>
              <input id="aantal_vragen" name="aantal_vragen" type="text" class="field text" size="5"  />
           </span>
        </li>


    </ul>
    <br />
    <input name="submit" type="submit" class="btn" tabindex="16" value="Aanmaken" />
    <a href="webpages/Cursus/showCursussen.jsp">(Terug)</a>
</form>


   <%
      //persist toets
   } else {
            EnqueteHelper ehelper = new EnqueteHelper();
            Enquetes enquete = new Enquetes();


            enquete.setNaam((String) request.getParameter("enquetenaam"));
            enquete.setAantalVragen((int) Integer.parseInt(request.getParameter("aantal_vragen")));
            enquete.setCursussen(chelper.getCursus((int) Integer.parseInt(request.getParameter("cursusid"))));
            ehelper.persistEnquete(enquete);

            response.sendRedirect("showCursussen.jsp");
        }
   %>

<div class="fix"></div>
<!--/post-->



<br class="fix" />


<%@include file="../../views/footer.jsp" %>